﻿using King.Box.Models.Db.Basic;
using King.Box.Models.Db.Sys;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace King.Box.DbProvider
{
    /// <summary>
    /// 初始化
    /// </summary>
    public class DalContextInitialize : DbContext
    {
        public DalContextInitialize():base("ConnectionString") { }

        public DalContextInitialize(string conn) : base(conn)
        {
            this.Configuration.AutoDetectChangesEnabled = true;
            this.Configuration.LazyLoadingEnabled = true;
        }

        public DbSet<Sys_Menu> Sys_Menu { get; set; }
        public DbSet<Sys_User> Sys_User { get; set; }
        public DbSet<Sys_Role> Sys_Role { get; set; }
        public DbSet<Sys_Permission> Sys_Permission { get; set; }
        public DbSet<Sys_User_Role> Sys_User_Role { get; set; }
        public DbSet<Sys_Role_Permission> Sys_Role_Permission { get; set; }
        public DbSet<Basic_Dictionary> Basic_Dictionary { get; set; }


        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
        }
    }
}
